﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Exchange_Add.aspx.cs" Inherits="JKF.Web.Points.Exchange_Add" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
        <%= RegScript("~/js/jquery.1.5.js")%>
        <%=RegScript("~/js/Common.js")%>
        <%=RegScript("~/js/jquery.json.js")%>
        <%=RegScript("~/js/jquery.nhis.js")%>
        <%=RegScript("~/js/jquery.rchis.js")%>
        <%=RegScript("~/js/jquery.validate.js")%>
        <%=RegScript("~/js/DatePicker/WdatePicker.js")%>
        <%=RegStyle("~/js/suggest/jquery.suggest.css")%>
        <%= RegScript("~/js/jquery-ui-custom.min.js")%>
        <%=RegScript("~/js/check.js")%>
    <script src="../../js/Uppop/tipswindown2.js"  type="text/javascript"></script>
        
    <link href="../../App_Themes/Theme2/Include.css"   rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        var isAdd = '<%=NoAddRedirect%>'  //没有权限跳转到提示页面
        var arrLinkBtn = new Array();
        arrLinkBtn.push(new Array('clearForm()', '兑换下一位')); //调用函数的参数要用双引号
        arrLinkBtn.push(new Array('clearForm2()', '兑换同一位')); //调用函数的参数要用双引号
        arrLinkBtn.push(new Array('parent.tipsWindown.close()', '返回列表')); //调用函数的参数要用双引号

        var AppPath = "<%=AppPath %>";
        var handler = AppPath + '/do/Points/Point_Exchange.do';
        var scid = '<%=P("exchangeKey") %>';//主键
        var GIFTS = ""; //兑换礼品
        var MEMO = ""; //备注
        var ACCOUNT = '<%=Account%>'; //操作员账号
        var EXCHANGE_NO = ""; //单号
        var CUSTOMER_KEY = ""; //顾客key
        var OLD_DEDUCT_POINT = 0;
        var POINT_DISCOUNT = 1;  //顾客兑换积分享受的折扣
        var DATE_EXCHANGE = '<%=DateTime.Now.ToString("yyyy-MM-dd") %>'; //如果是添加则取当前日期 如果是修改则是数据创建时间
        var ntEmpt = /^[^ ]+$/;
        var dtReg = /^\d{4}(\/|-)([1][0-2]|[1-9]|0[1-9])(\/|-)([1-2][0-9]|3[0-1]|[1-9]|0[1-9])( (0?[0-9]|1[0-9]|2[0-4])(:([0-5][0-9])){1,2})?$/;

        $(function () {
            bindGift();//绑定可兑换的礼品
            $("#liCustomer").show();
            $("#txtKeyword").focus(function () {
                if ($(this).val() == "请输入卡号或手机号") {
                    $("#txtKeyword").val("");
                }
            })

            $("#liError").hide();
            bindExchange();//编辑时 绑定数据
            $('#btnclose').click(function () {
                parent.tipsWindown.close();
            });

            $("#txtKeyword").focus(function () {
                if ($(this).val() == "请输入卡号或手机号") {
                    $("#txtKeyword").val("");
                }
            })

            $("#txtKeyword").blur(function () {
                if (CUSTOMER_KEY == "")
                    $("#txtKeyword").val("请输入卡号或手机号");

            })

            //选择顾客
            $("#txtKeyword").Suggest({ url: AppPath + '/do/Points/Point_Exchange.do', data: { ActionName: "SuggestCustomer" },
                onSelect: function (data, selectedIndex, selectedItem) {
                    var dr = data.Items[selectedIndex].split(' ');
                    $("#txtKeyword").val(dr.NAME);
                    $("#liCustomer").show();
                    $("#liError").hide();
                    clearForm(); //选择人员时 清空表单

                    CUSTOMER_KEY = $.FxNull(data.Items_value[selectedIndex], ""); //顾客key
                    $("#CARD_NO").text($.FxNull(dr[2], ""));  //卡号
                    $("#NAME").text($.FxNull(dr[0], ""));  //姓名
                    $("#MOBILE").text($.FxNull(dr[3], "")); //手机号
                    $("#LEVEL").text($.FxNull(dr[4], "")); //顾客级别
                    $("#LeftPoint").text($.FxNull(dr[5], ""));
                    POINT_DISCOUNT = $.FxNull(dr[6], "1");
                    if (scid != "") //更改顾客时只能新添记录，不能更改
                        scid = "";
                    return;
                }, mutiPage: true, minChars: 0, cache: true
            });
        });

        //添加或更新兑换记录，更新列表页面 pk为空为添加否则为更新
        function updateView(pk) {
            tr = $("<tr key=" + scid + "></tr>");
            $('<td></td>').appendTo(tr).html('<input  class="common_btn_edit mr12"  type="button" onclick="addExchange(' + "'" + scid + "'" + ')" ><input name="" type="button" class="common_btn_del mr12"  onclick="deleteExchange(' + "'" + scid + "'" + ')">');
            $('<td></td>').appendTo(tr).text(EXCHANGE_NO);
            $('<td></td>').appendTo(tr).text($("#CARD_NO").text());
            $('<td></td>').appendTo(tr).text($("#NAME").text());
            $('<td></td>').appendTo(tr).text($("#MOBILE").text());
            $('<td></td>').appendTo(tr).text(GIFTS);
            $('<td></td>').appendTo(tr).text($("#totalPoint").text());
            $('<td></td>').appendTo(tr).text(MEMO);
            $('<td></td>').appendTo(tr).text(ACCOUNT);
            $('<td></td>').appendTo(tr).text(DATE_EXCHANGE);
            window.parent.popRetuInfo($(tr), pk)
        }

        //编辑或查看时候绑定兑换主记录
        function bindExchange() {
            if ($.FxNull(scid, "").length > 0) { //如果主键不为空，初始化信息

                $.post(handler, { ActionName: "GetExchangeByKey", exchangeKey: $.FxNull(scid, "") }, function (ItemInfo) {
                    if (ItemInfo.MessageCode == "Ok") {
                        if (ItemInfo.Data) {
                            var item = ItemInfo.Data;

                            GIFTS = $.FxNull(item.GIFTS, "");
                            MEMO = $.FxNull(item.MEMO, "");
                            DATE_EXCHANGE = $.FxNull(item.DATE_EXCHANGE, "");
                            ACCOUNT = $.FxNull(item.ACCOUNT, "");
                            CUSTOMER_KEY = $.FxNull(item.CUSTOMER_KEY, "");
                            $("#CARD_NO").text($.FxNull(item.CARD_NO, ""));
                            $("#NAME").text($.FxNull(item.NAME, ""));
                            $("#MOBILE").text($.FxNull(item.MOBILE, ""));
                            $("#LEVEL").text($.FxNull(item.LEVEL_NAME, ""));
                            //$("#totalPoint").text($.FxNull(item.DEDUCT_POINT, ""));
                            $("#reDucePoint").text($.FxNull(item.DEDUCT_POINT, "")); //实扣积分
                            DATE_EXCHANGE = $.FxNull(item.DATE_EXCHANGE, "");
                            OLD_DEDUCT_POINT = $.FxNull(item.DEDUCT_POINT, "");
                            $("#LeftPoint").text($.FxNull(item.POINTS, "")); //剩余积分
                            POINT_DISCOUNT = $.FxNull(item.POINT_DISCOUNT, "1");  //兑换折扣
                            //记录修改之前消耗积分数，防止兑换记录发生修改，需重新判断剩余积分是否够用
                        }
                        return;
                    }
                    alert(ItemInfo.Message);
                }, "json");

                bindItem();//绑定兑换明细
            }
        }

        //编辑或查看时，绑定兑换明细
        function bindItem() {
            var tbody = $("#tbGift2").empty();

            $.post(handler, { ActionName: "GetExchangeItemByKey", exchangeKey: $.FxNull(scid, "") }, function (items) {
                if (items.error == true) {
                    ShowWarn(data.message);
                }
                else {
                    var deduct_num = 0;
                    var totel_point = 0;
                    $.each(items.Tables[0].Rows, function (i, item) {
                        need_point = $("#tbGift1 tr[key='" + item.GIFT_KEY + "']").find("td").eq(2).text(); //每一个所耗积分
                        tr = $("<tr key=" + item.GIFT_KEY + "></tr>").appendTo(tbody);
                        var strCancel = "<input type='submit' onclick=cancelSelect('" + item.GIFT_KEY + "') id='btnCancel' "
                         + " value='撤消' class='common_btn_w37' />"
                        $('<td  width="54"></td>').appendTo(tr).html(strCancel);
                        $('<td  width="180"></td>').appendTo(tr).text(item.NAME);
                        var strDedut = "<input style='width:65px' onblur='changeNum(this," + need_point + ")' oldValue='" + item.NUM + "'"
                        + "  id='txtdeduct_num' type='text' class='common_search_input w50' value='" + item.NUM + "' />";
                        $('<td  width="80"></td>').appendTo(tr).html(strDedut);
                        $('<td width="57"></td>').appendTo(tr).text(item.DEDUCT_POINT);
                        deduct_num += parseInt(item.NUM);
                        totel_point += parseInt(item.DEDUCT_POINT)
                    });
                    $("#totalNum").text($.FxNull(deduct_num, "")); //兑换数量
                    $("#totalPoint").text($.FxNull(totel_point, "")); //应扣积分
                }
            }, "json");
        }

        //通过手机号或卡号选择顾客
        function selectCustmoer2() {
            $.post(handler, { ActionName: "GetCustomer", keyword: $.FxNull($("#txtKeyword").val(), "") }, function (ItemInfo) {
                if (ItemInfo.MessageCode == "Ok") {
                    if (ItemInfo.Data) {
                        $("#liCustomer").show();
                        $("#liError").hide();
                        var item = ItemInfo.Data;
                        clearForm();
                        CUSTOMER_KEY = $.FxNull(item.CUSTOMER_KEY, ""); //顾客key
                        $("#CARD_NO").text($.FxNull(item.CARD_NO, ""));  //卡号
                        $("#NAME").text($.FxNull(item.NAME, ""));  //姓名
                        $("#MOBILE").text($.FxNull(item.MOBILE, "")); //手机号
                        $("#LEVEL").text($.FxNull(item.LEVEL_NAME, "")); //顾客级别
                        $("#LeftPoint").text($.FxNull(item.POINTS, ""));


                        if (scid != "") //更改顾客时只能新添记录，不能更改
                            scid = "";
                        return;
                    }
                }
                $("#liCustomer").hide();
                $("#liError").show();
                alert(ItemInfo.Message);
            }, "json");
        }

        //刷卡定位顾客
        function selCustmoerByShuaKa(selCardNo) {
            if (codeLength(selCardNo) != 8) {
                alert("不是8位的有效卡号");
                return;
            }

            $.post(AppPath + '/do/Points/Point_Exchange.do'
            , { ActionName: "GetCustomerByCard", cardNo: selCardNo }, function (ItemInfo) {
                if (ItemInfo.MessageCode == "Ok") {
                    if (ItemInfo.Data) {
                        $("#liCustomer").show();
                        $("#liError").hide();
                        var item = ItemInfo.Data;
                        clearForm(); //选择人员时清空表单
                        CUSTOMER_KEY = $.FxNull(item.CUSTOMER_KEY, ""); //顾客key
                        $("#CARD_NO").text($.FxNull(item.CARD_NO, ""));  //卡号
                        $("#NAME").text($.FxNull(item.NAME, ""));  //姓名
                        $("#MOBILE").text($.FxNull(item.MOBILE, "")); //手机号
                        $("#LEVEL").text($.FxNull(item.LEVEL_NAME, "")); //顾客级别
                        $("#LeftPoint").text($.FxNull(item.POINTS, ""));
                        if (scid != "") //更改顾客时只能新添记录，不能更改
                            scid = "";
                        return;
                    }
                    else {
                        alert("此卡在系统中不存在，请确认!");
                        $("#txtKeyword").val("请输入卡号或手机号");
                        clearForm();
                    }
                }
            }, "json");
        }

        //绑定礼品列表
        function bindGift() {
            var tbody = $("#tbGift1").empty();
            $.ajax({ global: true, url: handler, data: { ActionName: "GetGift" }, success: function (data) {
                if (data.error == true) {
                    ShowWarn(data.message);
                }
                else {
                    $.each(data.Tables[0].Rows, function (i, dr) {
                        tr = $("<tr key=" + dr.GIFT_KEY + "></tr>").appendTo(tbody);
                        var strSelect = "<input type='submit' onclick='selectGift($(this).parent().parent())'"
                        + "  id='btnSelect' value='选择' class='common_btn_w37'/>";
                        $('<td  width="54"></td>').appendTo(tr).html(strSelect);
                        $('<td  width="180"></td>').appendTo(tr).text(dr.NAME);
                        $('<td width="57"></td>').appendTo(tr).text(dr.NEED_POINT);
                        $('<td width="80"></td>').appendTo(tr).text(dr.MEMO);
                    })

                }
            }, dataType: "json", type: "POST", async: true });
        }

       //选择要兑换的礼品
       function selectGift(obj) {
           var giftKey = $(obj).attr("key");
           var tbody = $('#tbGift2');
           var tmpTr = $("#tbGift2 tr[key='" + giftKey + "']");
           need_point = $(obj).find("td").eq(2).text(); //每一个所耗积分
           if ($(tmpTr).html() != null) {//非第1次选择，兑换数量+1
               var deduct_num = $(tmpTr).find("[id='txtdeduct_num']").val() == "" ? 1 : parseInt($(tmpTr).find("[id='txtdeduct_num']").val()) + 1;
               $(tmpTr).find("[id='txtdeduct_num']").val(deduct_num);
               $(tmpTr).find("[id='txtdeduct_num']").attr("oldValue", deduct_num);
               $(tmpTr).find("td").eq(3).text(deduct_num * need_point); //等价积分=兑换数量*每件所需积分
           } else {//第一次选择         
               tr = $("<tr key=" + giftKey + "></tr>").appendTo(tbody);
               var strCancel = "<input type='submit' onclick=cancelSelect('" + giftKey + "') id='btnCancel' value='撤消' class='common_btn_w37' />"
               $('<td  width="54"></td>').appendTo(tr).html(strCancel);
               $('<td  width="180"></td>').appendTo(tr).text($(obj).find("td").eq(1).text());
               var strDedut = "<input style='width:65px' onblur='changeNum(this," + need_point + ")' oldValue='1'"
               +" id='txtdeduct_num' type='text' class='common_search_input w50' value='1' />";
               $('<td  width="80"></td>').appendTo(tr).html(strDedut);
               $('<td width="57"></td>').appendTo(tr).text(need_point);

               $(tr).find("#txtdeduct_num").forceNumber({
                   min: 0,
                   max: 18446744073709551615, // 2^64 - 1
                   scale:0                   // decimal places
               });
           }
  
           $("#totalNum").text(parseInt($("#totalNum").text()) + 1);
           $("#totalPoint").text(parseInt($("#totalPoint").text()) + parseInt(need_point));
           $("#reDucePoint").text(Math.ceil(parseInt($("#totalPoint").text()) * parseFloat(POINT_DISCOUNT))); //实扣积分=应扣积分*兑换折扣
       }

       //取消已选择的礼品
       function cancelSelect(giftKey) {
           var deduct_num = $("#tbGift2 tr[key='" + giftKey + "']").find("[id='txtdeduct_num']").val();
           deduct_num=deduct_num == "" ? 0 : deduct_num;

           var deduct_point = $("#tbGift2 tr[key='" + giftKey + "']").find("td").eq(3).text();
           deduct_point=deduct_point == "" ? 0 : deduct_point
           $("#totalNum").text(parseInt($("#totalNum").text()) - deduct_num); //兑换总数跟着变化
           $("#totalPoint").text(parseInt($("#totalPoint").text()) - deduct_point); //兑换所需积分跟着变化
           $("#reDucePoint").text(Math.ceil(parseInt($("#totalPoint").text()) * parseFloat(POINT_DISCOUNT))); //实扣积分=应扣积分*兑换折扣
           $("#tbGift2 tr[key='" + giftKey + "']").remove(); //取消已选择的礼品
       }

       //手工录入兑换数量
       function changeNum(obj,needPoint) {
           var oldNum = $(obj).attr("oldValue") == "" ? 0 : $(obj).attr("oldValue");
           var newNum = $(obj).val() == "" ? 0 : $(obj).val();

           $(obj).parent().parent().find("td").eq(3).text(newNum * needPoint)
           //兑换总数量=原兑换总数量+此礼品要兑换的数量-此礼品原兑换数量
           $("#totalNum").text(parseInt($("#totalNum").text()) + parseInt(newNum) - parseInt(oldNum));

           //兑换所需总积分=原所需积分+此礼品现所需积分-此礼品原需积分
           $("#totalPoint").text(parseInt($("#totalPoint").text()) + (newNum - oldNum) * needPoint);
           $("#reDucePoint").text(Math.ceil(parseInt($("#totalPoint").text()) * parseFloat(POINT_DISCOUNT))); //实扣积分=应扣积分*兑换折扣
           $(obj).attr("oldValue", newNum); //记录当前兑换数量，以便下次更改数量时计算所需总积分及兑换总数
       }

       //保存兑换记录
       function saveExchange() {
           if (CUSTOMER_KEY == "") {
               alert("未选择顾客");
               return;
           }
        
           if($("#totalNum").text()==""||$("#totalNum").text()=="0"){
               alert("未选择要兑换的礼品");
               return;
           }

           var newLeftPoint = 0;
           var leftPoint = $("#LeftPoint").text() == "" ? 0 : parseInt($("#LeftPoint").text());
           //var totalPoint = $("#totalPoint").text() == "" ? 0 : parseInt($("#totalPoint").text());
           var totalPoint = $("#reDucePoint").text() == "" ? 0 : parseInt($("#reDucePoint").text());
           
           if (scid == "") {//添加兑换记录
               if (parseInt(totalPoint) >parseInt(leftPoint)) {
                   alert("积分余额不足");
                   return;
               }
               newLeftPoint =parseInt(leftPoint) -parseInt(totalPoint); //剩余积分
           } else {//修改兑换记录
               if ((parseInt(totalPoint) -parseInt(OLD_DEDUCT_POINT)) > 0 
               && (parseInt(totalPoint) -parseInt(OLD_DEDUCT_POINT)) >parseInt(leftPoint)) {
                   alert("积分余额不足"); //修改兑换记录时，如果消耗了更多的积分，判断积分余额是否足够。
                   return;
               }
               newLeftPoint =parseInt(leftPoint) +parseInt(OLD_DEDUCT_POINT) -parseInt(totalPoint); //剩余积分
           }

           var items = getItems()
           $.post(handler,
            { ActionName: "SaveExchange", EXCHANGE_KEY: scid, customerKey: CUSTOMER_KEY, items: $.toJSON(items) },
            function (data) {
                if (data.MessageCode == "Ok") {//保存成功
                    GIFTS = getGifts(); //将兑换记录生成一个字符串

                    EXCHANGE_NO = data.Data.split("|")[1]; //兑换记录单号
                    if (scid == "")//新添
                    {
                        scid = data.Data.split("|")[0]; //兑换记录主键
                        updateView(""); //添加或修改数据成功后更新列表页面
                    }
                    else {
                        updateView(scid); //编辑
                    }
                    
                    OLD_DEDUCT_POINT = totalPoint; //记录所消耗积分，放在下次修改，判断积分余额是否够
                    $("#LeftPoint").text(newLeftPoint); //操作成功，更改剩余积分
                    $.popResultTip('操作成功', arrLinkBtn)
                    return;
                }
            }, "json");
        }

        //取得兑换明细json字符串
        function getItems() {
            var itemArr = [];
            $("#tbGift2 tr").each(function () {
                itemArr.push({
                GIFT_KEY: $.FxNull($(this).attr("key"), ""),
                GIFT_NAME: $.FxNull($(this).find("td").eq(1).text(), ""),
                NUM: $.FxNull($(this).find("#txtdeduct_num").val(), ""),
                DEDUCT_POINT: $.FxNull($(this).find("td").eq(3).text(), "")
                }); 
            });
           return itemArr;
       }

       //返回已兑换礼品名称及数量用逗号分隔
       function getGifts() {
           var giftNames="";
           $("#tbGift2 tr").each(function () {
               giftNames += $.FxNull($(this).find("td").eq(1).text(), "")
               + "(" + $.FxNull($(this).find("#txtdeduct_num").val(), "") + ")";
           });
           if (giftNames != "")
               return giftNames.substring(0, giftNames.length - 1);
           else
               return "";
       }

       //兑换下一位顾客时清空表单
       function clearForm() {
           $("#tbGift2").empty();//清空已选择礼品

           CUSTOMER_KEY = "";
           $("#txtKeyword").val("请输入卡号或手机号");
           $("#CARD_NO").text("");
           $("#NAME").text("");
           $("#LEVEL").text("");
           $("#LeftPoint").text("");           
           $("#MOBILE").text("");

           $("#totalNum").text("0"); //合计兑换数量
           $("#totalPoint").text("0"); //合计所需积分
           scid = "";//清空主键
           $('#resultTipDiv').dialog('close');  //关闭弹出提示层
       }

       //继续兑换本顾客清空表单
       function clearForm2() {
           $("#tbGift2").empty(); //清空已选择礼品

           $("#totalNum").text("0"); //合计兑换数量
           $("#totalPoint").text("0"); //合计所需积分
           scid = ""; //清空主键
           $('#resultTipDiv').dialog('close');  //关闭弹出提示层
       }
    </script>
</head>
<body id="modulebody">
 <OBJECT id=MWRFATL style="WIDTH: 0px; HEIGHT: 0px" 
codeBase=../Cap\rf35.cab#version=1,0,0,1
classid=CLSID:8C11E03B-3F3E-4457-A5A1-B9ECEC5FDA80></OBJECT> 

<SCRIPT charset="utf-8" LANGUAGE=javascript>
<!--
    function duKa() {
        var aa;
        var bb;

        //打开读卡器
        try {
            bb = MWRFATL.openReader(0, 115200);
        } catch (e) {
            alert("读卡器打开失败,确认是否已加载active控件");
            return;
        }
        if (bb == "读取硬件版本号失败,错误代码为-17") {
            alert("请确认是否已连接读卡器？");
            return "";
        }

        //打开卡片
        bb = MWRFATL.openCard(0);
        if (bb == "寻卡失败,错误代码为1") {
            aa = MWRFATL.CloseReader();  //关闭读卡器
            alert("寻卡失败,请确认是否已放入IC卡");
            return "";
        }

        //认证权限，将卡中密码与读卡器中密码去匹配
        aa = MWRFATL.mifare_authentication(0, 6);
        if (aa == "4") {
            MWRFATL.CloseCard(); //关闭卡片
            aa = MWRFATL.CloseReader();  //关闭读卡器        
            alert("卡密码验证失败!");
            return "";
        }

        //bb = MWRFATL.mifare_read(24); //读卡，反回卡号
        bb = MWRFATL.mifare_readHex(24);
        var kahao = "";
        if (bb.length > 8) {
            kahao = bb.substring(0, 8); //前8位为卡号
        } else {
            kahao = "";
            alert("不是8位有效卡");
        }

        MWRFATL.CloseCard();   //关闭卡片 
        aa = MWRFATL.CloseReader(); //关闭读卡器

        alert(kahao);
        if (kahao != "")
            selCustmoerByShuaKa(kahao); //通过卡号添加体验记录
        return kahao;
    }
//-->
</SCRIPT>
    <div class="pop__body" style="margin:5px 42px;">
        <p class="mb8 f14"><strong>第一步：请选择要兑换的礼品</strong></p>
        <div style="width:775px">
        <div style="width:371px; float:left;">
            <h4 class="title">兑换礼品</h4>
            <table width="371" border="0" cellspacing="0" cellpadding="0" class="common_table">            
                <thead >
                    <tr>
                    <th width="54" style="border-bottom:none;">操作</th>
                    <th width="180" style="border-bottom:none;">兑换礼品</th>
                    <th width="57" style="border-bottom:none;">等价积分</th>
                    <th width="80" style="border-bottom:none;">备注</th>
                    </tr>
                </thead>
            </table>

            <div style="width:371px;height:220px;overflow:auto;overflow-x:hidden;">
                <table width="371" border="0" cellspacing="0" cellpadding="0" id="tbGift1" class="common_table">
                    <tr key="1">
                        <td width="54">
                            <input type="submit" name="button" id="btnSelect"  onclick="selectGift($(this).parent().parent())" value="选择" class="common_btn_w37" /></td>
                        <td width="180">小熊玩具1</td>
                        <td width="57">10</td>
                        <td width="80">&nbsp;</td>
                    </tr>   
                    <tr key="2">
                        <td width="54">
                            <input type="submit" name="button" id="Submit1" onclick="selectGift($(this).parent().parent())" value="选择" class="common_btn_w37" /></td>
                        <td width="180">小熊玩具2</td>
                        <td width="57">20</td>
                        <td width="80">&nbsp;</td>
                    </tr> 
                    <tr key="3">
                        <td width="54">
                            <input type="submit" name="button" id="Submit2" onclick="selectGift($(this).parent().parent())" value="选择" class="common_btn_w37" /></td>
                        <td width="180">小熊玩具3</td>
                        <td width="57">30</td>
                        <td width="80">&nbsp;</td>
                    </tr>                    
                </table>
            </div>
            </div>

            <div style="width:371px; float:right;">
            <h4 class="title">已选兑换礼品</h4>
            <table width="371" border="0" cellspacing="0" cellpadding="0" class="common_table">         
                <thead >
                <tr>
                    <th width="54" style="border-bottom:none;">操作</th>
                    <th width="180" style="border-bottom:none;">兑换礼品</th>
                    <th width="80" style="border-bottom:none;">兑换数量</th>
                    <th width="57" style="border-bottom:none;">所需积分</th>
                </tr>
                </thead>
            </table>
            <div style="width:371px;height:220px;overflow:auto;overflow-x:hidden;">
                <table width="371" border="0" cellspacing="0" cellpadding="0"  id="tbGift2" class="common_table">
              
                </table>
            </div>
        </div>
    </div>
        <br clear="all" />
        <div class="total">
            <span class="mr30">合计兑换数量为：<span id="totalNum" class="fred f14">0</span></span>
            <span class="mr30">应扣积分：<span id="totalPoint" class="fred  f14">0</span></span>
            <span class="mr30">实扣积分：<span id="reDucePoint" class="fred  f14">0</span></span>
            <span style=" color:Red">注：实扣积分=应扣积分乘于积分兑换可享受的折扣</span>
        </div>

        <p class="mb8 f14"><strong>第二步：请刷卡或手工录入卡号，进行兑换</strong></p>
        <div class="common_search">
            <ul class="user_name">
                <li>
                     <input id="txtKeyword"  type="text" class="login_input" value="请输入卡号或手机号" style="width:214px; color:#767676;" />&nbsp;                        <input name="" type="button" class="btn_duka"  value=" " onclick="duKa()"/>
                </li>
                <li id="liCustomer" style="width:100%">
                     <span class="mr16" id="CUSTOMER_KEY" key=''>会员卡号：<strong class="f14" id="CARD_NO"></strong></span>
                     <span class="mr16">姓名：<strong  class="f14" id="NAME"></strong></span>  
                     <span class="mr16">级别：<strong  class="f14" id="LEVEL"></strong></span> 
                     <span class="mr16">手机号：<strong  class="f14" id="MOBILE"></strong></span>
                     <span class="mr16" style=" margin-right:5px">剩余积分：<strong  id="LeftPoint"></strong></span>                    
                </li>
                <li id="liError"><span  class="fred f14">系统未找到满足条件的顾客,请确认是否输入有误!</span></li>
            </ul>       
        </div>
    </div>

    <div class="pop_btn">
        <input id="BtnSave" onclick="saveExchange()" type="button" class="common_btn_save mr30 mb25" value="" />
	    <input id="btnclose" type="button" class="common_btn_remove mb25" value=" "  />
    </div>
</body>
</html>
